﻿using ComicWeb.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ComicWeb.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class proc_ClassificationController : ControllerBase
    {
        private readonly ShopContext _context;
        public proc_ClassificationController(ShopContext context)
        {
            _context = context;
        }
        // Post: api/VClassifications
        /// <summary>
        /// 检索漫画显示
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<proc_Classification>> GetVClassifications(string TypeID, string ComicsTypeOne,string CountryID)
        {
            string i="%", j = "%", k = "%";
            if (TypeID != "0" && TypeID!=null) i = TypeID;
            if (ComicsTypeOne != "0" && ComicsTypeOne != null) j = ComicsTypeOne;
            if (CountryID != "0" && CountryID != null) k = CountryID;
            var data = _context.proc_Classifications.FromSqlRaw($"exec proc_Classification '{i}' , '{j}' , '{k}'").ToList();
            return data;
        }
    }
}
